<template>
	<view class="bigbox">
		<view class="ht_box5_box">
			<view class="ht_box5" @click="hetong(1)">刷新</view>
			<view class="ht_box5" @click="tijiao()">发送合同</view>
			<view class="ht_box5" @click="sc_hetong()">合同生成</view>
		</view>
		<view v-for="item in ht_list" class="ht_box">
			<view class="ht_box1">{{item.query02}}</view>
			<view class="ht_box3">
				<view class="ht_box4" @click="copy(item.query06)" v-if="item.query06!=null&&item.query06!=''">转发</view>
				<view class="ht_box2" @click="see(item.query06)" v-if="item.query06!=null&&item.query06!=''">查看</view>
			</view>
		</view>
		<tanchuang v-if="tc_tijiao" :dspSta=zhuangtai1[index] @tcgb="tanchuaung_gb" @tcnr="tanchuaung_nr"></tanchuang>
	</view>
</template>

<script>
	import tanchuang from '../../component/tanchuang.vue'
	export default {
		components:{tanchuang},
		data() {
			return {
				tc_tijiao:false,
				zhuangtai1:[],
				ht_list:[],
				id:''
			}
		},
		onLoad:function(option){
			this.id = option.id
			this.hetong()
		},
		methods: {
			tijiao:function(){
				this.tc_tijiao = true
			},
			tanchuaung_nr:function(data){
				console.log(data);
				console.log(this.zhuangtai1[this.index])
				// this.xiayibu()
				this.$post('buse/fxjBuse_02/addFxjBuseitem_09',{
					rid:this.id,
					// query02:this.zhuangtai1[this.index],
					query02:data.spjg,
					query03:data.spyj,
					query05:data.nbyj
				}).then((res)=>{
					console.log(res.data,7777)
					if(res.data.success){
						uni.showToast({
							title:'发送成功',
							icon:'none'
						})
						this.tc_tijiao = false
						setTimeout(()=>{
							uni.navigateBack({
							    delta: 1
							});
						},1000)
					}else if(!res.data.success){
						uni.showToast({
							title: res.data.message,
							icon:'none'
						})
					}
				})
			},
			tanchuaung_gb:function(data){
				this.tc_tijiao = false;
			},
			sc_hetong:function(){
				uni.showModal({
				    title: '提示',
				    content: '您确定要生成合同吗？',
				    success: (res) => {
				        if (res.confirm) {
							uni.showLoading({
							    title: '加载中'
							});
				            console.log('用户点击确定');
							this.$get('fxj/base/contract',{
								id:this.id
							}).then(res=>{
								console.log(res.data)
								if(res.data.success){
									uni.showToast({
										title:'生成成功',
										icon:'none'
									})
									this.hetong()
								}
							})
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
				
			},
			copy:function(url){
				uni.setClipboardData({
				    data: url,
				    success: () => {
				        uni.showToast({
				        	title:'复制成功,请到浏览器粘贴下载',
							icon:'none'
				        })
				    }
				});
			},
			see:function(url){
				console.log(url,888)
				uni.downloadFile({
				  url: url,
				  success: function (res) {
				    var filePath = res.tempFilePath;
					uni.openDocument({
					  filePath: filePath,
					  success: function (res) {
					    console.log('打开文档成功');
					  }
					});
				  }
				});
			},
			hetong:function(e){
				this.$get('buse/fxjBuse_02/listFxjBuseitem_05ByMainId',{
					rid:this.id,
					pageNo:1,
					pageSize:999
				}).then((res)=>{
					if(res.data.success && e ==1){
						uni.showToast({
							title:'刷新成功',
							icon:'none'
						})
					}
					console.log(res.data,55555)
					this.ht_list = res.data.result.records
				})
			},
		}
	}
</script>

<style>
	.ht_box5_box{
		display: flex;
		justify-content: flex-end;
		align-items: center;
		margin: 20rpx 0;
	}
	.ht_box5{
		width: 160rpx;
		margin-left: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 10rpx;
		box-sizing: border-box;
		border: 1px solid #0F77FE;
		border-radius: 10rpx;
		color: #FFFFFF;
		background-color: #0F77FE;
	}
	.ht_box4{
		margin-left: 10rpx;
		padding: 10rpx;
		box-sizing: border-box;
		border: 1px solid #0F77FE;
		border-radius: 10rpx;
		color: #FFFFFF;
		background-color: #0F77FE;
	}
	.ht_box3{
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.ht_box2{
		margin-left: 10rpx;
		padding: 10rpx;
		box-sizing: border-box;
		border: 1px solid #0F77FE;
		border-radius: 10rpx;
		color: #0F77FE;
	}
	.ht_box1{
		width: 70%;
	}
	.ht_box{
		height: 80rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1px solid #CCCCCC;
	}
	.bigbox{
		padding: 30rpx;
		box-sizing: border-box;
	}
</style>
